package satir.command;

import satir.SatirGame;
import satir.player.Player;

/**
 * Random reorder players.
 * @version 3.0 April 2012
 * @author Creative Family
 */

public class SwapPlayersOrderCmd implements Command {

    /** The satir game. */
    private SatirGame satirGame;

    /**
     * Instantiates a new swap players order command.
     * @param satirGame
     *            the Satir game
     */
    public SwapPlayersOrderCmd(final SatirGame satirGame) {
	this.satirGame = satirGame;
    }

    /**
     * Execute to swap player order.
     */
    public void execute() {
	for (int i = 0; i < satirGame.getNumOfPlayer(); i++) {
	    int j = (int) (Math.random() * satirGame.getNumOfPlayer());

	    Player temp = satirGame.getPlayers(i);
	    satirGame.getArrayListPlayer().set(i, satirGame.getPlayers(j));
	    satirGame.getArrayListPlayer().set(j, temp);
	}
    }
}
